package com.example.springstudy.common;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 请求状态码
 *
 * @author Pan
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ResultCode {

    /**
     * 状态码
     */
    private Integer code;

    /**
     * 消息
     */
    private String message;


    public static ResultCode success() {
        return new ResultCode(200, "请求成功");
    }

    public static ResultCode badRequest() {
        return new ResultCode(400, "无效请求");
    }

    public static ResultCode notLogin() {
        return new ResultCode(401, "未登录");
    }

    public static ResultCode unauthorized() {
        return new ResultCode(403, "禁止访问");
    }

    public static ResultCode notFound() {
        return new ResultCode(404, "未找到");
    }

    public static ResultCode error() {
        return new ResultCode(500, "请求错误");
    }

    public static ResultCode warn() {
        return new ResultCode(501, "请求警告");
    }
}


